package com.example.aplicacion_comedor;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.Toast;

/**
 * Created by Administrador on 31/08/13.
 */
public class Registro extends Activity implements View.OnClickListener{
    // Array of options --> ArrayAdapter --> ListView

    //List view: {views: da_items.xml}
    Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.actividad_registro);

        button=(Button)findViewById(R.id.btnCrear);
        button.setOnClickListener(this);

        Spinner sp  =(Spinner)findViewById(R.id.spinner);
        ArrayAdapter adapter = ArrayAdapter.createFromResource(
                this,R.array.versiones,android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        sp.setAdapter(adapter);

        sp.setOnItemSelectedListener(new OnItemSelectedListener(){

            public void onItemSelected(AdapterView<?> parentView, View selectedItemView,
                                       int position, long id){
                Toast.makeText(parentView.getContext(),"Has seleccionado " +
                    parentView.getItemAtPosition(position).toString(), Toast.LENGTH_LONG).show();
            }
            public void onNothingSelected(AdapterView<?> parentView){

            }
        });
    }

    @Override
    public void onClick(View arg0){
        //Toast Presenta un cuadro de dialogo
        Toast t=Toast.makeText(this,"Registro Guardado",Toast.LENGTH_SHORT);
        t.show();
    }

}